<template>
  <div>
    <city-header></city-header>
    <city-search :cities="cities"></city-search>
    <city-list :cityList="hotCityList" :allCity="cities" :alphabet="letter"></city-list>
    <city-alphabet :allCity="cities" @change="handleAlphabetClick"></city-alphabet>
  </div>
</template>

<script>
import CityHeader from './components/CityHeader.vue'
import CitySearch from './components/CitySearch.vue'
import CityList from './components/CityList.vue'
import CityAlphabet from './components/CityAlphabet.vue'
import axios from 'axios'
export default {
  name: 'City',
  data () {
    return {
      hotCityList: [],
      cities: {},
      letter: ''
    }
  },
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityAlphabet
  },
  methods: {
    cityInfo () {
      axios.get('/api/city.json').then(this.getResponseInfo)
    },
    getResponseInfo (response) {
      var res = response.data
      if (res.ret) {
        this.hotCityList = res.data.hotCities
        this.cities = res.data.cities
      }
    },
    handleAlphabetClick (value) {
      //  console.log(value)
      this.letter = value
    }
  },
  mounted () {
    this.cityInfo()
  }
}
</script>

<style lang="stylus" scoped>
</style>
